<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Models\Traits\Filters;

class UserPresentCard extends Model
{
    use Filters;

    protected $guarded = [];

    public function presentCard()
    {
        return $this->hasOne(PresentCard::class,'id','card_id');
    }

    public function transfrom_data()
    {
        switch($this->card_level){
            case '1':
                $level = " 【月卡】";
                $price = 499;
                break;
            case '2':
                $level = " 【季卡】";
                $price = 1300;
                break;
            case '3':
                $level = " 【年卡】";
                $price = 4990;
                break;
            default:
                break;
        }
        return [
            'image' => config('app.img_url').$this->presentCard->log_image,
            'name' => $this->presentCard->name.$level,
            'price' => $price,
            'code' => $this->code,
            'is_used' => $this->is_used,
        ];
    }



}
